package com.roadjava.rbac.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.roadjava.rbac.bean.entity.LogsDO;
import com.roadjava.rbac.bean.req.logs.LogsPageReq;
import com.roadjava.rbac.bean.res.Result;
import com.roadjava.rbac.bean.vo.LogsVO;
import com.roadjava.rbac.mapper.LogsMapper;
import com.roadjava.rbac.service.LogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @Description:日志的删除，分页查询
 * @Author: chenling
 * @Date: 2024/12/17 10:28
 */
@Service
public class LogsServiceImpl extends ServiceImpl<LogsMapper, LogsDO> implements LogsService {

    @Autowired
    private LogsMapper logsMapper;

    @Override
    public Result<List<LogsVO>> queryPage(LogsPageReq pageReq) {
        Long count = getBaseMapper().queryCount(pageReq);
        if (count.equals(0L)) {
            return Result.buildSuccess(Collections.emptyList(), count);
        }
        List<LogsVO> vos = getBaseMapper().queryList(pageReq);
        return Result.buildSuccess(vos, count);
    }

    @Override
    public void deleteById(Long id) {
        logsMapper.deleteById(id);
    }
}